import javax.management.Query;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Demo1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int ret = 0;

        for (int i = 197; i <= 10000000; i++) {
            String temp = i + "";
            char[] ch = temp.toCharArray();
            int len = ch.length;
            Queue<Integer> queue = method(i, len);
            int sum = 0;//各个位数之和
            for (int j : queue) {
                sum += j;
            }
            int n = 0;
            while (n < i) {
                n = sum;
                queue.offer(n);
                sum = sum - queue.poll() + n;
            }
            if (n == i) {
                System.out.println(i);
                ret = Math.max(ret, i);
            }
        }


        scan.close();
    }

    private static Queue<Integer> method(int num, int len) {
        int[] arr = new int[len];
        int count = len - 1;
        while (num != 0) {
            arr[count--] = num % 10;
            num /= 10;
        }
        Queue<Integer> queue = new LinkedList<>();
        for (int i : arr) {
            queue.offer(i);
        }
        return queue;
    }
}
